// 导入需要的config和request
import confing from '../config/config.js';
import request from '../util/request.js';


// 申明请求对象
const workTicketRequest = {
    // workTicket请求的基本url
    BASE_URL : confing.CZ_URL + "/workorder",
    /**
     * 保存字典信息
     * @param {*} workTicket 
     * @param {*} callback 
     */
    save(workTicket,callback){
        if(workTicket){
            request.post(this.BASE_URL + "/save",workTicket,callback);
        }
    },
    // 请求的API
    list(page = 1,limit = 10,workTicket,callbcak){
       console.log(workTicket);
        // url
        let url = this.BASE_URL + "/list?page=" + page + "&limit=" + limit;
        if(workTicket){
            if(workTicket.workTicketId){
                url += "&workTicketId=" + workTicket.workTicketId;
            }
            if(workTicket.workTicketName){
                url += "&workTicketName=" + workTicket.workTicketName;
            }
            if(workTicket.sourceCode){
                url += "&sourceCode=" + workTicket.sourceCode;
            }
            if(workTicket.productCode){
                url += "&productCode=" + workTicket.productCode;
            }
            if(workTicket.productName){
                url += "&productName=" + workTicket.productName;
            }
            if(workTicket.clientCode){
                url += "&clientCode=" + workTicket.clientCode;
            }
            if(workTicket.clientName){
                url += "&clientName=" + workTicket.clientName;
            }
            if(workTicket.requestDate){
                url += "&requestDate=" + workTicket.requestDate;
            }

        }
        // 发送请求
        request.get(url,callbcak);
    }
}

// 将workTicketRequest暴漏出去
export default workTicketRequest;